/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package project1;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ButtonGroup;
import javax.swing.table.DefaultTableModel;


/**
 *
 * @author haihip
 */
class ComboItem
{
    private String key;
    private String value;

    public ComboItem(String key, String value)
    {
        this.key = key;
        this.value = value;
    }

    @Override
    public String toString()
    {
        return key;
    }

    public String getKey()
    {
        return key;
    }

    public String getValue()
    {
        return value;
    }
}
public class MarkView extends javax.swing.JPanel {

    /**
     * Creates new form ScoreView
     */
    public MarkView() {
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
        }
        initComponents();
        loadinfo();
        ButtonGroup radGroupStudents = new ButtonGroup();
        radGroupStudents.add(rad_allsub);
        radGroupStudents.add(rad_oncesub);
        ButtonGroup radClassOpt = new ButtonGroup();
        radClassOpt.add(rad_all);
        radClassOpt.add(rad_failed);
        radClassOpt.add(rad_passed);
        ButtonGroup radGroupFind = new ButtonGroup();
        radGroupFind.add(rad_FindCLass);
        radGroupFind.add(rad_FindSV);
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        btn_home = new javax.swing.JLabel();
        txt_home = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        input_sinhvien = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        input_class = new javax.swing.JTextField();
        rad_allsub = new javax.swing.JRadioButton();
        rad_oncesub = new javax.swing.JRadioButton();
        listMonHoc = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        rad_all = new javax.swing.JRadioButton();
        rad_failed = new javax.swing.JRadioButton();
        rad_passed = new javax.swing.JRadioButton();
        checkMark = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        checkCaNhan = new javax.swing.JCheckBox();
        rad_FindSV = new javax.swing.JRadioButton();
        rad_FindCLass = new javax.swing.JRadioButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();

        setBackground(new java.awt.Color(255, 255, 255));
        setMaximumSize(new java.awt.Dimension(1024, 700));
        setMinimumSize(new java.awt.Dimension(1024, 700));
        setPreferredSize(new java.awt.Dimension(1024, 700));

        jPanel1.setBackground(new java.awt.Color(250, 249, 249));
        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel1.setMaximumSize(new java.awt.Dimension(1024, 124));
        jPanel1.setMinimumSize(new java.awt.Dimension(1024, 124));
        jPanel1.setPreferredSize(new java.awt.Dimension(1024, 124));

        btn_home.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        btn_home.setIcon(new javax.swing.ImageIcon(getClass().getResource("/project1/Views/images/home.png"))); // NOI18N
        btn_home.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        btn_home.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btn_home.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT);
        btn_home.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btn_homeMouseClicked(evt);
            }
        });

        txt_home.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        txt_home.setText("Thông tin chung");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(46, 46, 46)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(btn_home)
                    .addComponent(txt_home))
                .addContainerGap(884, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(btn_home)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txt_home)
                .addContainerGap())
        );

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));
        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Tuỳ chọn"));
        jPanel2.setMaximumSize(new java.awt.Dimension(952, 129));
        jPanel2.setMinimumSize(new java.awt.Dimension(952, 129));
        jPanel2.setPreferredSize(new java.awt.Dimension(952, 129));

        jLabel1.setText("Tìm sinh viên:");

        input_sinhvien.setText("Nhập họ tên hoặc mã số sinh viên");
        input_sinhvien.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                input_sinhvienMouseClicked(evt);
            }
        });

        jLabel2.setText("Tìm Lớp học:");

        input_class.setText("Nhập mã lớp học");
        input_class.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                input_classMouseClicked(evt);
            }
        });

        rad_allsub.setBackground(new java.awt.Color(255, 255, 255));
        rad_allsub.setText("Xem toàn bộ");
        rad_allsub.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rad_allsubActionPerformed(evt);
            }
        });

        rad_oncesub.setBackground(new java.awt.Color(255, 255, 255));
        rad_oncesub.setSelected(true);
        rad_oncesub.setText("Xem theo môn học");
        rad_oncesub.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rad_oncesubActionPerformed(evt);
            }
        });

        jLabel3.setText("Chọn môn học: ");

        rad_all.setBackground(new java.awt.Color(255, 255, 255));
        rad_all.setSelected(true);
        rad_all.setText("Xem toàn bộ");

        rad_failed.setBackground(new java.awt.Color(255, 255, 255));
        rad_failed.setText("Chỉ trượt");

        rad_passed.setBackground(new java.awt.Color(255, 255, 255));
        rad_passed.setText("Chỉ đỗ");

        checkMark.setText("Tra cứu điểm thi");
        checkMark.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkMarkActionPerformed(evt);
            }
        });

        jPanel3.setBackground(new java.awt.Color(204, 204, 204));
        jPanel3.setMaximumSize(new java.awt.Dimension(5, 100));
        jPanel3.setMinimumSize(new java.awt.Dimension(5, 100));
        jPanel3.setPreferredSize(new java.awt.Dimension(5, 100));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 5, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        jPanel4.setBackground(new java.awt.Color(204, 204, 204));
        jPanel4.setMaximumSize(new java.awt.Dimension(5, 100));
        jPanel4.setMinimumSize(new java.awt.Dimension(5, 100));

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 5, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        checkCaNhan.setBackground(new java.awt.Color(255, 255, 255));
        checkCaNhan.setText("Cá nhân");
        checkCaNhan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                checkCaNhanActionPerformed(evt);
            }
        });

        rad_FindSV.setBackground(new java.awt.Color(255, 255, 255));
        rad_FindSV.setSelected(true);
        rad_FindSV.setText("Tìm theo sinh viên");

        rad_FindCLass.setBackground(new java.awt.Color(255, 255, 255));
        rad_FindCLass.setText("Tìm theo lớp");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(input_sinhvien, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 10, Short.MAX_VALUE)
                        .addComponent(checkCaNhan))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(rad_allsub)
                            .addComponent(jLabel3))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(rad_oncesub)
                            .addComponent(listMonHoc, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(18, 18, 18)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(60, 60, 60)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(input_class, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(jPanel2Layout.createSequentialGroup()
                            .addComponent(rad_FindSV)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(rad_FindCLass))
                        .addGroup(jPanel2Layout.createSequentialGroup()
                            .addComponent(rad_all)
                            .addGap(18, 18, 18)
                            .addComponent(rad_failed)
                            .addGap(18, 18, 18)
                            .addComponent(rad_passed))))
                .addGap(53, 53, 53)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(38, 38, 38)
                .addComponent(checkMark)
                .addGap(31, 31, 31))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(input_sinhvien, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2)
                            .addComponent(input_class, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(checkCaNhan))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(rad_allsub)
                            .addComponent(rad_oncesub)
                            .addComponent(rad_all)
                            .addComponent(rad_failed)
                            .addComponent(rad_passed))
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(14, 14, 14)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(listMonHoc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel3)))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGap(18, 18, 18)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(rad_FindSV)
                                    .addComponent(rad_FindCLass)))))
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(checkMark, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null}
            },
            new String [] {
                "STT", "Tên sinh viên", "Tên môn học", "Điểm giữa kỳ", "Điểm cuối kỳ", "Điểm Project", "Loại"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.setMaximumSize(new java.awt.Dimension(300, 64));
        jTable1.setMinimumSize(new java.awt.Dimension(300, 64));
        jScrollPane1.setViewportView(jTable1);
        if (jTable1.getColumnModel().getColumnCount() > 0) {
            jTable1.getColumnModel().getColumn(0).setResizable(false);
            jTable1.getColumnModel().getColumn(0).setPreferredWidth(10);
            jTable1.getColumnModel().getColumn(1).setResizable(false);
            jTable1.getColumnModel().getColumn(2).setResizable(false);
            jTable1.getColumnModel().getColumn(3).setResizable(false);
            jTable1.getColumnModel().getColumn(3).setPreferredWidth(30);
            jTable1.getColumnModel().getColumn(4).setResizable(false);
            jTable1.getColumnModel().getColumn(4).setPreferredWidth(30);
            jTable1.getColumnModel().getColumn(5).setResizable(false);
            jTable1.getColumnModel().getColumn(5).setPreferredWidth(30);
            jTable1.getColumnModel().getColumn(6).setResizable(false);
            jTable1.getColumnModel().getColumn(6).setPreferredWidth(30);
        }

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(36, 36, 36)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jScrollPane1))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(32, 32, 32)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 373, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(36, 36, 36))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btn_homeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_homeMouseClicked
        // TODO add your handling code here:
        project1.Frame.setFrame(project1.Frame.homeView);
    }//GEN-LAST:event_btn_homeMouseClicked

    private void rad_oncesubActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rad_oncesubActionPerformed
        // TODO add your handling code here:
            listMonHoc.setEnabled(true);
    }//GEN-LAST:event_rad_oncesubActionPerformed

    private void rad_allsubActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rad_allsubActionPerformed
        // TODO add your handling code here:
        listMonHoc.setEnabled(false);

    }//GEN-LAST:event_rad_allsubActionPerformed

    private void checkCaNhanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkCaNhanActionPerformed
        // TODO add your handling code here:
        if(checkCaNhan.isSelected())
        {
           input_sinhvien.setEnabled(false);
            System.out.println(Project1.User[10]);
            loadListMonHoc(Project1.User[10]);
        }
        else
        {
            input_sinhvien.setEnabled(true);
            loadListMonHoc();
        }
    }//GEN-LAST:event_checkCaNhanActionPerformed

    private void checkMarkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_checkMarkActionPerformed
        // TODO add your handling code here:
        if(rad_FindSV.isSelected())
        loadDiem();
        else
        loadDiemInLop();
    }//GEN-LAST:event_checkMarkActionPerformed

    private void input_sinhvienMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_input_sinhvienMouseClicked
        // TODO add your handling code here:
       // if(input_sinhvien.getText().equals("Nhập họ tên hoặc mã số sinh viên"))
            input_sinhvien.setText("");
    }//GEN-LAST:event_input_sinhvienMouseClicked

    private void input_classMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_input_classMouseClicked
        // TODO add your handling code here:
        input_class.setText("");
    }//GEN-LAST:event_input_classMouseClicked
SqlFunc sql = new SqlFunc();
void loadinfo()
{
        
        loadListMonHoc();
}
void loadListMonHoc()
{
    try {
                listMonHoc.removeAllItems();
            ResultSet rs = sql.select("select MSMH,tenMon from monhoc");
            while(rs.next())
            {
                listMonHoc.addItem(new ComboItem(rs.getString("tenMon"),rs.getString("MSMH")));
            }   
        } catch (SQLException ex) {
            Logger.getLogger(MarkView.class.getName()).log(Level.SEVERE, null, ex);
        }
}
//select `monhoc`.`MSMH` as `MSMH`,`monhoc`.`tenMon` as `tenMon` from monhoc,lop,svInLop where `monhoc`.`MSMH`=`lop`.`MSMH` and `svInLop`.`MSSV` = '20118410' and `svInLop`.`MaLop` = `lop`.`MaLop`
void loadListMonHoc(String mssv)
{
    try {
            listMonHoc.removeAllItems();
                
        ResultSet rs = sql.select("select `monhoc`.`MSMH` as `MSMH`,`monhoc`.`tenMon` as `tenMon` from monhoc,lop,svInLop where `monhoc`.`MSMH`=`lop`.`MSMH` and `svInLop`.`MSSV` = '"+mssv+"' and `svInLop`.`MaLop` = `lop`.`MaLop`");
            while(rs.next())
            {
                listMonHoc.addItem(new ComboItem(rs.getString("tenMon"),rs.getString("MSMH")));
            }   
        } catch (SQLException ex) {
            Logger.getLogger(MarkView.class.getName()).log(Level.SEVERE, null, ex);
        }
}
void loadDiemInLop()
{
    Float diem = 0f;
    String query = "select `diem`.`MALOP` as MaLop,`diem`.`MSSV` as MSSV,`user`.`ten` as ten,diemP,diemGK,diemCK,`monhoc`.`tenMon` as tenMon,`lop`.`MSMH` as MSMH from diem,lop,monhoc,user,sinhvien where `user`.`ID_User`=`sinhvien`.`ID_User` and `diem`.`MSSV` = `sinhvien`.`MSSV` and `diem`.`MALOP` = `lop`.`MALOP` and `lop`.`MSMH` = `monhoc`.`MSMH` and `diem`.`MALOP`='"+input_class.getText()+"'";
    System.out.println(query);
    DefaultTableModel defaultModel = (DefaultTableModel) jTable1.getModel(); 
        int num=jTable1.getRowCount();
        for(int i =0;i<num;i++)
        {
            defaultModel.removeRow(0);
        }
    try {
        ResultSet rs = sql.select(query);
        while(rs.next())
        {
            String loai="";
            String diemP=rs.getString("diemP");
            String diemGK=rs.getString("diemGK");
            String diemCK=rs.getString("diemCK");
            if(Float.parseFloat(diemP) < 3f || Float.parseFloat(diemGK)<3f || Float.parseFloat(diemCK)<3f)
                loai="F";
            else
            {
                ResultSet rs1=sql.select("select * from monhoc where MSMH='"+rs.getString("MSMH")+"'");
                if(rs1.next())
                {
                    diem = Float.parseFloat(diemP)*Float.parseFloat(rs1.getString("heSoP"))+Float.parseFloat(diemGK)*Float.parseFloat(rs1.getString("heSoGK"))+Float.parseFloat(diemCK)*Float.parseFloat(rs1.getString("heSoCK"));
                    if(diem<4f)
                        loai="F";
                    else if(diem<5f)
                        loai="D";
                    else if(diem<5.5f)
                        loai="D+";
                    else if(diem<6.5f)
                        loai="C";
                    else if(diem<7f)
                        loai="C+";
                    else if(diem<8f)
                        loai="B";
                    else if(diem<8.5f)
                        loai="B+";
                    else if(diem<9.4f)
                        loai="A";
                    else
                        loai="A+";
                }
            }
            if(rad_failed.isSelected())
            {
                if(loai.equals("F"))
                defaultModel.insertRow(jTable1.getRowCount(), new Object [] {jTable1.getRowCount(),rs.getString("ten"),rs.getString("tenMon"), rs.getString("diemGK"), rs.getString("diemCK"), rs.getString("diemP"),loai});
            }
            else if(rad_passed.isSelected())
            {
                if(diem>=4f)
                    defaultModel.insertRow(jTable1.getRowCount(), new Object [] {jTable1.getRowCount(),rs.getString("ten"),rs.getString("tenMon"), rs.getString("diemGK"), rs.getString("diemCK"), rs.getString("diemP"),loai});
            }
            else
            {
                defaultModel.insertRow(jTable1.getRowCount(), new Object [] {jTable1.getRowCount(),rs.getString("ten"),rs.getString("tenMon"), rs.getString("diemGK"), rs.getString("diemCK"), rs.getString("diemP"),loai});
            }
        }   
     } catch (SQLException ex) {
            Logger.getLogger(MarkView.class.getName()).log(Level.SEVERE, null, ex);
        }
    
}
void loadDiem()
{
    String qCaNhan="";
    String query="";
    String qSub="";
    if(checkCaNhan.isSelected())
        qCaNhan=" and `diem`.`MSSV` ='"+Project1.User[10]+"'";
    else
    {
    try
    {
      NumberFormat.getInstance().parse(input_sinhvien.getText());
        qCaNhan=" and `diem`.`MSSV`='"+input_sinhvien.getText()+"'";
    }
    catch(ParseException e)
    {
        qCaNhan="and `user`.`ten` LIKE '%"+input_sinhvien.getText()+"%'";
    }
    }
    if(rad_oncesub.isSelected())
    {
        ComboItem mon = (ComboItem) listMonHoc.getSelectedItem();
        if(mon!=null)
            qSub=" and `monhoc`.`MSMH` ='"+mon.getValue()+"'";
    }
    query = "select `diem`.`MALOP` as MaLop,`diem`.`MSSV` as MSSV,`user`.`ten` as ten,diemP,diemGK,diemCK,`monhoc`.`tenMon` as tenMon,`lop`.`MSMH` as MSMH from diem,lop,monhoc,user,sinhvien where `user`.`ID_User`=`sinhvien`.`ID_User` and `diem`.`MSSV` = `sinhvien`.`MSSV` and `diem`.`MALOP` = `lop`.`MALOP` and `lop`.`MSMH` = `monhoc`.`MSMH` "+qCaNhan+qSub;
    System.out.println(query);
    DefaultTableModel defaultModel = (DefaultTableModel) jTable1.getModel(); 
        int num=jTable1.getRowCount();
        for(int i =0;i<num;i++)
        {
            defaultModel.removeRow(0);
        }
    try {
        ResultSet rs = sql.select(query);
        while(rs.next())
        {
            String loai="";
            String diemP=rs.getString("diemP");
            String diemGK=rs.getString("diemGK");
            String diemCK=rs.getString("diemCK");
            if(Float.parseFloat(diemP) < 3f || Float.parseFloat(diemGK)<3f || Float.parseFloat(diemCK)<3f)
                loai="F";
            else
            {
                ResultSet rs1=sql.select("select * from monhoc where MSMH='"+rs.getString("MSMH")+"'");
                if(rs1.next())
                {
                    Float diem = Float.parseFloat(diemP)*Float.parseFloat(rs1.getString("heSoP"))+Float.parseFloat(diemGK)*Float.parseFloat(rs1.getString("heSoGK"))+Float.parseFloat(diemCK)*Float.parseFloat(rs1.getString("heSoCK"));
                    if(diem<4f)
                        loai="F";
                    else if(diem<5f)
                        loai="D";
                    else if(diem<5.5f)
                        loai="D+";
                    else if(diem<6.5f)
                        loai="C";
                    else if(diem<7f)
                        loai="C+";
                    else if(diem<8f)
                        loai="B";
                    else if(diem<8.5f)
                        loai="B+";
                    else if(diem<9.4f)
                        loai="A";
                    else
                        loai="A+";
                }
            }
            
            defaultModel.insertRow(jTable1.getRowCount(), new Object [] {jTable1.getRowCount(),rs.getString("ten"),rs.getString("tenMon"), rs.getString("diemGK"), rs.getString("diemCK"), rs.getString("diemP"),loai});
        }   
     } catch (SQLException ex) {
            Logger.getLogger(MarkView.class.getName()).log(Level.SEVERE, null, ex);
        }
    
}
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel btn_home;
    private javax.swing.JCheckBox checkCaNhan;
    private javax.swing.JButton checkMark;
    private javax.swing.JTextField input_class;
    private javax.swing.JTextField input_sinhvien;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTable jTable1;
    private javax.swing.JComboBox listMonHoc;
    private javax.swing.JRadioButton rad_FindCLass;
    private javax.swing.JRadioButton rad_FindSV;
    private javax.swing.JRadioButton rad_all;
    private javax.swing.JRadioButton rad_allsub;
    private javax.swing.JRadioButton rad_failed;
    private javax.swing.JRadioButton rad_oncesub;
    private javax.swing.JRadioButton rad_passed;
    private javax.swing.JLabel txt_home;
    // End of variables declaration//GEN-END:variables
}
